<template>
  <div class="app-container">
    <el-form :inline="true" :model="queryParams" class="demo-form-inline">
      <el-form-item label="ID" prop="userId">
        <el-input v-model="queryParams.userId" placeholder="id" />
      </el-form-item>
      <el-form-item label="开始日期" prop="startTime">
        <el-date-picker v-model="queryParams.startTime" type="datetime" placeholder="选择开始日期"
          value-format="yyyy-MM-dd HH:mm:ss" />
      </el-form-item>
      <el-form-item label="结束日期" prop="endTime">
        <el-date-picker v-model="queryParams.endTime" type="datetime" placeholder="选择结束日期"
          value-format="yyyy-MM-dd HH:mm:ss" />
      </el-form-item>
      <!-- <el-form-item label="账单状态" prop="type">
        <el-select v-model="queryParams.type" placeholder="请选择">
          <el-option v-for="(item,index) in statusOptions" :key="index" :label="item.label" :value="item.id" />
        </el-select>
      </el-form-item> -->

      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
        <el-button type="primary" @click="reset">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="listLoading" :data="list" element-loading-text="Loading" border fit highlight-current-row>
      <!-- <el-table-column align="center" label="序号" width="95">
        <template slot-scope="scope">
          {{ scope.$index }}
        </template>
      </el-table-column> -->
      <el-table-column label="用户ID" align="center" prop="userId" />
      <el-table-column label="购买金额" align="center" prop="totalAmount" />

      <el-table-column label="产品信息" align="center" prop="product.name">
        <template slot-scope="scope">
          {{ scope.row.product.name + scope.row.product.holdTime + '天' }}
        </template>
      </el-table-column>
      <el-table-column label="购买时间" align="center" prop="createTime" />
      <!-- <el-table-column label="操作前余额		" align="center" prop="beforeBalance" />
      <el-table-column label="操作后余额		" align="center" prop="thenBalance" />
      <el-table-column label="交易类型		" align="center" prop="type	">
        <template slot-scope="scope">
          {{ setTypeTxt(scope.row.type) }}
        </template>
      </el-table-column>
      <el-table-column label="交易状态	" align="center" prop="state">
        <template slot-scope="scope">
          {{ setStateTxt(scope.row.state) }}
        </template>
      </el-table-column> -->

      <!-- <el-table-column label="操作人" align="center" prop="userId" /> -->

      <!-- <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button type="text" @click="handleShowInfo(scope.row)">详情</el-button>

        </template>
      </el-table-column> -->
    </el-table>
    <div class="pagination">
      <el-pagination :current-page.sync="queryParams.pageNum" :page-sizes="[10, 20, 30, 40]"
        :page-size.sync="queryParams.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total"
        @size-change="fetchData" @current-change="fetchData" />
    </div>
  </div>
</template>

<script>
import { dividendList } from '@/api/table'
export default {
  components: {
    

  },
  data() {
    return {
      list: null,
      listLoading: true,
      total: 0,
      typeOptions: [
        { label: '虚拟货币', value: 'usdt' },
        { label: '人民币', value: 'rmb' }
      ],
      statusOptions: [
        { id: 1, label: '充值USDT' },
        { id: 2, label: '充值TRX' },
        { id: 3, label: '提现' },
        { id: 4, label: 'TRX投注' },
        { id: 5, label: 'AI托管收益到账' },
        { id: 6, label: '转账TRX' },
        { id: 7, label: '转账USDT' },
        { id: 8, label: '转账燃料' },
        { id: 9, label: '提现驳回' },
        { id: 10, label: '收到TRX转账' },
        { id: 11, label: '收到USDT转账' },
        { id: 12, label: '收到燃料转账' },
        { id: 13, label: 'TRX投注盈利' },
        { id: 14, label: 'TRX兑换USDT' },
        { id: 15, label: 'USDT兑换TRX' },
        { id: 16, label: '当日业绩增加trx' },
        { id: 17, label: '购买AI托管' },
        { id: 18, label: '下注消耗燃料' },
        { id: 19, label: '购买AI托管消耗燃料' },
        { id: 20, label: '投注和局返还TRX' },
        { id: 21, label: '投注和局返还燃料' },
        { id: 22, label: '待释放保险仓每日清零' },
        { id: 23, label: '保险仓每日千分之一加到待释放保险仓（待释放保险仓金额增加）' },
        { id: 24, label: '保险仓每日千分之一加到待释放保险仓(保险仓金额减少)' },
        { id: 25, label: '交易消耗待释放保险仓金额' },
        { id: 26, label: '提现燃料减少' },
        { id: 27, label: '提现驳回增加燃料' },
        { id: 28, label: '转账燃料减少' },
        { id: 29, label: '购买燃料' }

      ],
      queryParams: {

        userId: '',
        pageNum: 1,
        pageSize: 10,
        type: '17',
        startTime: '',
        endTime: ''

      }
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.listLoading = true
      dividendList(this.queryParams).then(response => {
        this.list = response.data.records
        this.listLoading = false
        this.total = response.data.total
      })
    },
    handleShowInfo(e) {
      this.$refs.showInfo.show(e)
    },
    setStateTxt(index) {
      let str = ''
      switch (Number(index)) {
        case 1:
          str = '审核中'
          break
        case 2:
          str = '已完成'
          break
        case 3:
          str = '失败'
          break
      }
      return str
    },
    setTypeTxt(index) {
      let str = ''
      switch (Number(index)) {
        case 1:
          str = '充值USDT'
          break
        case 2:
          str = '充值TRX'
          break
        case 3:
          str = '提现'
          break
        case 4:
          str = 'TRX投注'
          break
        case 5:
          str = 'AI托管收益到账'
          break
        case 6:
          str = '转账TRX'
          break
        case 7:
          str = '转账USDT'
          break
        case 8:
          str = '转账燃料'
          break
        case 9:
          str = '提现驳回'
          break
        case 10:
          str = '收到TRX转账'
          break
        case 11:
          str = '收到USDT转账'
          break
        case 12:
          str = '收到燃料转账'
          break
        case 13:
          str = 'TRX投注盈利'
          break
        case 14:
          str = 'TRX兑换USDT'
          break
        case 15:
          str = 'USDT兑换TRX'
          break
        case 16:
          str = '当日业绩增加trx'
          break
        case 17:
          str = '购买AI托管'
          break
        case 18:
          str = '下注消耗燃料'
          break
        case 19:
          str = '购买AI托管消耗燃料'
          break
        case 20:
          str = '投注和局返还TRX'
          break
        case 21:
          str = '投注和局返还燃料'
          break
        case 22:
          str = '待释放保险仓每日清零'
          break
        case 23:
          str = '保险仓每日千分之一加到待释放保险仓（待释放保险仓金额增加）'
          break
        case 24:
          str = '保险仓每日千分之一加到待释放保险仓(保险仓金额减少)'
          break
        case 25:
          str = '交易消耗待释放保险仓金额'
          break
        case 26:
          str = '提现燃料减少'
          break
        case 27:
          str = '提现驳回增加燃料'
          break
        case 28:
          str = '转账燃料减少'
          break
        case 29:
          str = '购买燃料'
          break
      }
      return str
    },
    onSubmit() {
      this.queryParams.page = 1
      this.fetchData()
    },
    reset() {
      this.queryParams = {

        hash: '',

        pageNum: 1,
        pageSize: 10,
        status: ''
      }
      this.fetchData()
    },
    handleAdd() {
      this.$refs.add.show()
    },
    handleEdit(e) {
      this.$refs.add.edit(e)
    },
    handleDel(e) {
      this.$confirm('此操作将删除公告, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        communityDelete(e).then(res => {
          this.fetchData()
          this.$message({
            type: 'success',
            message: '成功!'
          })
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消操作'
        })
      })
    }
  }
}
</script>
